package com.ldu.exam.dao;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.ldu.exam.model.RoleModel;

public interface RoleRepository extends JpaRepository<RoleModel, Serializable>  
{
	Page<RoleModel> findByNameContaining( String name, Pageable page) ;

	@Modifying
	@Query(nativeQuery=true,value="delete from rel_role_resource where role_id=?1")
	void removeRelResources( String id) ;
	
	@Modifying
	@Query(nativeQuery=true, value="delete from rel_role_menu where role_id=?1")
	void removeRelMenus ( String id ) ;
	
	List<RoleModel> findByName(String name);
}
